'''
https://www.nowcoder.com/practice/36fb0fd3c656480c92b569258a1223d5
'''

import sys

a = sys.stdin.readline().strip().split(' ')
n, aim = int(a[0]), int(a[1])
nums = sys.stdin.readline().strip().split(' ')
nums = list(map(int, nums))

dic = {0: -1}
sum = 0
ans = -1
for i, num in enumerate(nums):
    sum += num
    # if (range_sum := sum - pre_sum) == aim: pass     =>  find sum - aim, find if pre_sum exist
    if sum - aim in dic:
        ans = max(ans, i - dic[sum - aim])
    if sum not in dic:
        dic[sum] = i
sys.stdout.write(str(ans))
